package com.gzsxy.esjy.request.impl;

import com.gzsxy.esjy.mapping.MappingEntity;
import io.netty.buffer.ByteBuf;
import io.netty.handler.codec.http.multipart.DiskFileUpload;

/**
 * 基础请求
 * @author zhangxiaolong
 * @date 2022/7/6 9:36
 */
public class BaseRequest {

	private MappingEntity entity ;
	
	private ByteBuf content ;
	
	private int currentLength=0 ;
	
	private String body ;
	
	private String path ;
	
	private boolean isKeepAlive ;
	
	private boolean end = false ;
	
	private DiskFileUpload fileUpload ;
	
	private String remoteUser ;
	
	private String remoteAddress ;
	
	/**
	 * 获取maping
	 * @return
	 */
	public MappingEntity getMappingEntity() {
		return entity ;
	}
	
	/**
	 * 获取maping
	 * @return
	 */
	public BaseRequest setMappingEntity(MappingEntity entity) {
		this.entity = entity ;
		return this ;
	}
	
	protected String getRequestBody() {
		return body ;
	}

	public String getPath() {
		return path;
	}

	public BaseRequest setPath(String path) {
		this.path = path;
		return this ;
	}

	public boolean isKeepAlive() {
		return isKeepAlive;
	}

	public BaseRequest setKeepAlive(boolean isKeepAlive) {
		this.isKeepAlive = isKeepAlive;
		return this ;
	}

	public boolean isEnd() {
		return end;
	}
	
	public void end() {
		this.end = true ;
	}

	public int getCurrentLength() {
		return currentLength;
	}

	public BaseRequest setCurrentLength(int currentLength) {
		this.currentLength = currentLength;
		return this ;
	}

	public BaseRequest addLength(int readableBytes) {
		this.currentLength = currentLength+readableBytes;
		return this ;
	}
	
	public ByteBuf getContent() {
		return content;
	}

	public BaseRequest setContent(ByteBuf content) {
		this.content = content;
		return this ;
	}
	
	public BaseRequest setRequestBody(String body) {
		this.body = body ;
		return this ;
	}

	public DiskFileUpload getFileUpload() {
		return fileUpload;
	}

	public BaseRequest setFileUpload(DiskFileUpload fileUpload) {
		this.fileUpload = fileUpload;
		return this ;
	}
	
	public String getRemoteUser() {
		return this.remoteUser;
	}

	public String getRemoteAddress() {
		return this.remoteAddress;
	}

	public BaseRequest setRemoteUser(String remoteUser) {
		this.remoteUser = remoteUser;
		return this ;
	}

	public BaseRequest setRemoteAddress(String remoteAddress) {
		this.remoteAddress = remoteAddress;
		return this ;
	}
}
